package com.deng.util
{
	import com.deng.common.model.CommonModelLocator;
	
	import mx.controls.Alert;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;
	
	public class ObjectFactory
	{
		public function ObjectFactory()
		{
		}
		public static function getInstance(str:String,rst:Function,ft:Function):RemoteObject{
			var ro:RemoteObject = new RemoteObject();
			ro.destination = str;
			if(ft == null){
				ro.addEventListener(FaultEvent.FAULT,flt);
			}else{
				ro.addEventListener(FaultEvent.FAULT,ft);
			}
			ro.addEventListener(ResultEvent.RESULT,rst);
			return ro;			
		}
		private static function flt(ft:FaultEvent):void{
			CommonModelLocator.getInstance().progress.endRun();
			Alert.show(ft.fault.getStackTrace());
		}
	}
}